package game.java3D.bibliotheque;

import java.awt.Color;

import javax.media.j3d.PointArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;

public class CerclePoint extends Shape3D {

	public CerclePoint(int nbPoints, Color color) {

		Point3f points[] = new Point3f[nbPoints + 1];
		Color3f colors[] = new Color3f[nbPoints + 1];

		for (int i = 0; i < nbPoints; i++) {
			points[i] = new Point3f(0.5f * (float) Math.cos(2 * i * Math.PI
					/ nbPoints), 0.5f * (float) Math.sin(2 * i * Math.PI
					/ nbPoints), 0f);

			colors[i] = new Color3f(color);
		}

		// Origine
		points[nbPoints] = new Point3f(0f, 0f, 0f);
		colors[nbPoints] = new Color3f(Color.red);

		// Construction de l'objet geometrique PointArray
		PointArray pointArray = new PointArray(nbPoints + 1,
				PointArray.COORDINATES | PointArray.COLOR_3);
		pointArray.setCoordinates(0, points);
		pointArray.setColors(0, colors);

		this.setGeometry(pointArray);
	}
}
